<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>easyui form file</title>
    <link rel="stylesheet" type="text/css" href="lib/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="lib/easyui/themes/icon.css">
    <script type="text/javascript" src="lib/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="lib/easyui/jquery.easyui.min.js"></script>
</head>
<body>
<form enctype="multipart/form-data" method="post" action="http://localhost:9998/postFile" onsubmit="return before()">
    <div style="margin-bottom:20px">
        <input name="name" class="easyui-textbox" label="Name:" labelPosition="top" style="width:100%">
    </div>
    <div style="margin-bottom:20px">
        <input name="file1" class="easyui-filebox" label="File1:" labelPosition="top" data-options="prompt:'上传图片', accept:'image/jpeg,image/gif,image/png'" style="width:100%">
    </div>
  <!--  <div style="margin-bottom:40px">
        <input class="easyui-filebox" label="File2:" labelPosition="top" data-options="prompt:'Choose another file...'" style="width:100%">
    </div>-->
    <div style="margin-bottom:40px">
        <input type="submit" value="提交啦">
    </div>
</form>
<script>
    function before() {
        const fileName = $('[name=file1]').val()
        console.log(fileName, fileName.substring(fileName.lastIndexOf('.')))
        let i = ['.jpg', '.png', '.jpeg', '.gif'].indexOf(fileName.substring(fileName.lastIndexOf('.')))
        console.log('i=', i)
        if (i == -1) {
            return false
        }
        console.log('y')
        return false
    }
</script>
</body>
</html>